package com.lilinling.yinzhi.order.web;

import com.lilinling.common.utils.JwtInfo;
import com.lilinling.common.utils.JwtUtils;
import com.lilinling.common.utils.PageUtils;
import com.lilinling.common.utils.R;
import com.lilinling.yinzhi.order.entity.OrderEntity;
import com.lilinling.yinzhi.order.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Api("用户订单页面接口")
@RestController
@RequestMapping("order/userOrderWeb")
public class UserOrderWebController {
    @Autowired
    private OrderService orderService;

    @ApiOperation("获取用户订单列表")
    @PostMapping("/auth/userOrderList")
    public R getUserOrderList(@RequestParam Map<String, Object> params, HttpServletRequest request ){
        JwtInfo jwtInfo = JwtUtils.getUserIdByJwtToken(request);
        Long userId = jwtInfo.getId();
        PageUtils page = orderService.getUserOrderList(params,userId);
        return R.ok().put("page",page);
    }
}
